package org.codefinger.dao.impl.mssql;

import java.util.List;

import org.codefinger.dao.impl.DataAccesser;
import org.codefinger.dao.impl.Querier;
import org.codefinger.dao.impl.QueryBuilder;
import org.codefinger.dao.impl.sql.Column;
import org.codefinger.dao.impl.sql.ColumnItem;
import org.codefinger.dao.impl.sql.Group;
import org.codefinger.dao.impl.sql.GroupItem;
import org.codefinger.dao.impl.sql.Join;
import org.codefinger.dao.impl.sql.JoinItem;
import org.codefinger.dao.impl.sql.Order;
import org.codefinger.dao.impl.sql.OrderItem;
import org.codefinger.dao.impl.sql.UValueItem;
import org.codefinger.dao.impl.sql.Union;
import org.codefinger.dao.impl.sql.UnionItem;

public class SQLServerQueryBuilder extends QueryBuilder {

	public SQLServerQueryBuilder(DataAccesser dataAccesser) {
		super(dataAccesser);
	}

	public SQLServerQueryBuilder() {
		super();
	}

	public SQLServerQueryBuilder(List<UValueItem> uValues) {
		super(uValues);
	}

	public SQLServerQueryBuilder(DataAccesser dataAccesser, String table) {
		super(dataAccesser, table);
	}

	@Override
	public Querier buildQuerier() {
		return new SQLServerQuerier(dataAccesser.getDataSource(),//
				isDistinct, new Column(columns.toArray(new ColumnItem[columns.size()])),//
				from, //
				joins == null ? null : new Join(joins.toArray(new JoinItem[joins.size()])),//
				where,//
				groups == null ? null : new Group(groups.toArray(new GroupItem[groups.size()])),//
				having, //
				unions == null ? null : new Union(unions.toArray(new UnionItem[unions.size()])),//
				orders == null ? null : new Order(orders.toArray(new OrderItem[orders.size()])),//
				aliases.toArray(new String[aliases.size()])//
		);
	}

}
